import requests

url = 'https://api-c.liepin.com/api/com.liepin.searchfront4c.pc-search-job'

head = {
    'accept': 'application/json, text/plain, */*',
    'accept-encoding': 'gzip, deflate, br, zstd',
    'accept-language': 'zh-CN,zh;q=0.9',
    'cache-control': 'no-cache',
    'connection': 'keep-alive',
    'content-type': 'application/json;charset=UTF-8',
    'cookie': '__uuid=1736692513338.97; __tlog=1736692513342.79%7C00000000%7C00000000%7Csm_pc_013%7Csm_pc_013; XSRF-TOKEN=82QUb1-vRdSAlNWCTlKHDA; __gc_id=49fdeadc40254607b877f95f12d7609b; _ga=GA1.1.1603506161.1736692534; Hm_lvt_a2647413544f5a04f00da7eee0d5e200=1736692534; HMACCOUNT=6000BD1092539678; acw_tc=1a0c650a17366925339548441e003a439aa5618024cf0c4cac67a1c04ab059; Hm_lpvt_a2647413544f5a04f00da7eee0d5e200=1736692767; __session_seq=8; __tlg_event_seq=76; _ga_54YTJKWN86=GS1.1.1736692533.1.1.1736692783.0.0.0',
    'host': 'api-c.liepin.com',
    'origin': 'https://www.liepin.com',
    'pragma': 'no-cache',
    'referer': 'https://www.liepin.com/',
    'sec-ch-ua': '"Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-site',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
    'x-client-type': 'web',
    'x-fscp-bi-stat': '{"location": "https://www.liepin.com/zhaopin/?inputFrom=www_index&workYearCode=0&key=python&scene=input&ckId=j4p58f31qugqn1evmmdyigup8nsco0x9&dq="}',
    'x-fscp-fe-version': '',
    'x-fscp-std-info': '{"client_id": "40108"}',
    'x-fscp-trace-id': 'bc05d181-00e9-499f-8c6e-9c2ef8481622',
    'x-fscp-version': '1.1',
    'x-requested-with': 'XMLHttpRequest',
    'x-xsrf-token': '82QUb1-vRdSAlNWCTlKHDA'
}

data = {
    'data': {
        'mainSearchPcConditionForm': {
            'city': "410",
            'dq': "410",
            'pubTime': "",
            'currentPage': 0,
            'pageSize': 40,
            'key': "python",
            'suggestTag': "",
            'compId': "",
            'compKind': "",
            'compName': "",
            'compScale': "",
            'compStage': "",
            'compTag': "",
            'eduLevel': "",
            'industry': "",
            'jobKind': "",
            'salary': "",
            'workYearCode': "0"
        },
        'passThroughForm': {
            'scene': "input",
            'skId': "",
            'fkId': "",
            'ckId': "kpfqpmy5r7qa1xp9a0s1159mdennux18",
            'suggest': None
        }
    }
}

try:
    res = requests.post(url, json=data, headers=head)
    res.raise_for_status()  # 检查请求是否成功
    response_data = res.json()  # 解析 JSON 响应
    print(response_data)
except requests.exceptions.HTTPError as http_err:
    print(f"HTTP 错误发生: {http_err}")
except requests.exceptions.RequestException as err:
    print(f"请求错误: {err}")